const express = require('express')
const axios = require('axios')
const app = express()
const port = 1008


app.all('*', (req, res, next) => {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "X-Requested-With");
  res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
  res.header("X-Powered-By",' 3.2.1')
  res.header("Content-Type", "application/json;charset=utf-8");
  next();
});
app.get('/getdata', async (req, res) => {
  const resp = await axios.get('http://api.weatherdt.com/common/?area=101160901&type=forecast|observe|alarm|index|air&key=fd034bf8fe70289698ec4ea79876feaa')
  console.log(resp.data, 'data');
  return res.send({
    data: resp.data
  })
})

app.listen(port, () => console.log(`Example app listening on port ${port}!`))